home *** CD-ROM | disk | FTP | other *** search
- Path: fc.hp.com!news
- From: Rick Wells <rwells>
- Newsgroups: comp.lang.c
- Subject: Re: A Linked List Problem
- Date: 22 Feb 1996 16:59:32 GMT
- Organization: Hewlett-Packard Fort Collins Site
- Message-ID: <4gi7dk$alk@fcnews.fc.hp.com>
- References: <96053.015114X60CC@CUNYVM.CUNY.EDU>
- NNTP-Posting-Host: blkbear.fc.hp.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; HP-UX A.09.07 9000/715)
- X-URL: news:96053.015114X60CC@CUNYVM.CUNY.EDU
-
- SHAHZAD ANJUM MALIK <X60CC@CUNYVM.CUNY.EDU> wrote:
- >Hi!
- > I am trying to create a small program using Linked Lists. Actually, I
- >am planning to use Linked Lists in Linked Lists. A simple application of the
- >program would be to add a customer name etc and then add a magazine to be
- >subscribed to the customer, and if the customer wants add a 2nd and 3rd and
- >so on. For adding new customers I am using Linked Lists of nested structures.
- >Structures look like this:
- >
- >struct CustName
- > {
- > char LastName[15];
- > char ID#[5];
- > };
- >struct Magazine
- > {
- > char MagName[20];
- > struct Magazine *nextMag;
- > };
- >struct CustProfile
- > {
- > struct CustName Name;
- > struct Magazine Mag;
- > struct CustProfile *next;
- > };
- >typedef struct CustProfile ELEMENT;
- >typedef ELEMENT *LINK;
- >
- >
- .
- .
- .
- >
- > current->Mag = current->Mag.nextMag;
- > current->next = NULL;
- >}
- >
- >
- > The problem is that the complier (MSC 6.00) gives syntax error on the
- > 2nd last line. I have been trying to remove the mistake for several
- > days but useless. The error for "current->Mag = current->Mag.nextMag"
- > is " Erro No. '=' incompatible types.
- .
- .
- .
-
- Your problem is that Mag in structure CustProfile is not a pointer where
- current->Mag.nextMag is. You need to change Mag to be
-
- struct Magazine *Mag;
-
- Of course, you will also have to change your other code (not shown above)
- to reflect the change such as dereferencing Mag when you access it's
- elements and you will have to malloc structures of type struct Magazine
- and add them to your Mag list.
-
- Hope this helps, Rick
-
-